<script lang="ts" setup>
import { ref, defineProps, computed, watchEffect, toRaw } from 'vue'
import { anyFuncCall } from '/@/utils'

const props = defineProps({
  renderOpts: Object,
  params: Object
});

const text = ref('')

watchEffect(() => {

  const value = props.params.row[props.params.column.id]
  if (!value) return;
  anyFuncCall(props.renderOpts.props.columnRaw.formatter, null, value, toRaw(props)).then((res: string) => {
    text.value = res
  }).catch(() => {
    text.value = String(value)
  })
})
</script>

<template>
  <span>
    {{ text }}
  </span>
</template>